<template>
  <div class="layout">
    <Layout>
      <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed">
        <Menu :theme="theme2" :open-names="['1']" accordion>
          <Submenu name="1">
            <template slot="title">
              <Icon type="ios-paper" />火灾监测与预警
            </template>
            <MenuItem name="1-1">
              <router-link to="/fire-monitor/safe-evaluate">安全评估分析</router-link>
            </MenuItem>
            <MenuItem name="1-2">
              <router-link to="/fire-monitor/danger-log">隐患历史记录</router-link>
            </MenuItem>
          </Submenu>
          <Submenu name="2">
            <template slot="title">
              <Icon type="ios-people" />实战指挥分析
            </template>
            <MenuItem name="2-1">
              <router-link to="/combat-command/hazard-log">灾情历史记录</router-link>
            </MenuItem>
            <MenuItem name="2-2">
              <router-link to="/combat-command/equipment-list">队站装备情况</router-link>
            </MenuItem>
          </Submenu>
          <Submenu name="3">
            <template slot="title">
              <Icon type="ios-stats" />党政建设分析
            </template>
            <MenuGroup>
              <MenuItem name="3-1">
                <router-link to="/political/education">政治教育情况</router-link>
              </MenuItem>
              <MenuItem name="3-2">
                <router-link to="/political/news">党政要闻情况</router-link>
              </MenuItem>
              <MenuItem name="3-3">
                <router-link to="/political/forum">论坛活跃情况</router-link>
              </MenuItem>
            </MenuGroup>
          </Submenu>
          <Submenu name="4">
            <template slot="title">
              <Icon type="ios-stats" />综合效能评估
            </template>
            <MenuGroup>
              <MenuItem name="4-1">
                <router-link to="/eff/personal">人员评估</router-link>
              </MenuItem>
              <MenuItem name="4-2">
                <router-link to="/eff/group">部门评估</router-link>
              </MenuItem>
            </MenuGroup>
          </Submenu>
          <Submenu name="5">
            <template slot="title">
              <Icon type="ios-stats" />业务风险管控
            </template>
            <MenuGroup>
              <MenuItem name="5-1">
                <router-link to="/risk-control/abnormal">异常性风险</router-link>
              </MenuItem>
              <MenuItem name="5-2">
                <router-link to="/risk-control/timeliness">时效性风险</router-link>
              </MenuItem>
              <MenuItem name="5-3">
                <router-link to="/risk-control/legal">合规性风险</router-link>
              </MenuItem>
            </MenuGroup>
          </Submenu>
          <Submenu name="6">
            <template slot="title">
              <Icon type="ios-stats" />问题台账管理
            </template>
            <MenuGroup>
              <MenuItem name="6-1">
                <router-link to="/risk-control/abnormal">问题记录</router-link>
              </MenuItem>
            </MenuGroup>
          </Submenu>
        </Menu>
      </Sider>
      <Layout>
        <Header :style="{padding: 0}" class="layout-header-bar">
          <Icon
            @click.native="collapsedSider"
            :class="rotateIcon"
            :style="{margin: '0 20px'}"
            type="md-menu"
            size="24"
          ></Icon>
        </Header>
        <Content :style="{margin: '20px', background: '#fff', minHeight: '260px'}">
          <router-view></router-view>
        </Content>
      </Layout>
    </Layout>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isCollapsed: false
    };
  },
  computed: {
    rotateIcon() {
      return ["menu-icon", this.isCollapsed ? "rotate-icon" : ""];
    },
    menuitemClasses() {
      return ["menu-item", this.isCollapsed ? "collapsed-menu" : ""];
    }
  },
  methods: {
    collapsedSider() {
      this.$refs.side1.toggleCollapse();
    }
  }
};
</script>

<style scoped>
.layout {
  border: 1px solid #d7dde4;
  background: #f5f7f9;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}
.layout-header-bar {
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
.layout-logo-left {
  width: 90%;
  height: 30px;
  background: #5b6270;
  border-radius: 3px;
  margin: 15px auto;
}
.menu-icon {
  transition: all 0.3s;
}
.rotate-icon {
  transform: rotate(-90deg);
}
.menu-item span {
  display: inline-block;
  overflow: hidden;
  width: 69px;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  transition: width 0.2s ease 0.2s;
}
.menu-item i {
  transform: translateX(0px);
  transition: font-size 0.2s ease, transform 0.2s ease;
  vertical-align: middle;
  font-size: 16px;
}
.collapsed-menu span {
  width: 0px;
  transition: width 0.2s ease;
}
.collapsed-menu i {
  transform: translateX(5px);
  transition: font-size 0.2s ease 0.2s, transform 0.2s ease 0.2s;
  vertical-align: middle;
  font-size: 22px;
}
</style>

